<?
$fileArray = array('../01_news/academic.xml','../01_news/news.xml','../01_news/award.xml');
$fileArrayItem = array('academic_news','news_news','award_news');
$dom = new DOMDocument();
$gate = $dom->load($fileArray[$_POST['status']]);

if ( $gate == true ){
	//echo 'readOk';
	$targetNode = $dom->getElementsByTagName($fileArrayItem[$_POST['status']])->item(0);
	
	$item = $dom->createElement($fileArrayItem[$_POST['status']]);
	$serial = $dom->createElement('serial',$_POST['serial']); 
	$serial = $item->appendChild($serial);
	$dateb = $dom->createElement('dateb',$_POST['dateb']); 
	$dateb = $item->appendChild($dateb);
	$datee = $dom->createElement('datee',$_POST['datee']); 
	$datee = $item->appendChild($datee);
	$title = $dom->createElement('title',$_POST['title']); 
	$title = $item->appendChild($title);
	$text = $dom->createElement('text',$_POST['text']); 
	$text = $item->appendChild($text);
	
	$targetNode->parentNode->insertBefore( $item, $targetNode);
	//print $item;
	
	echo $dom -> saveXML();
	unlink($fileArray[$_POST['status']]);
	$dom->save($fileArray[$_POST['status']]);

} else if ( $gate == false )
{
	//echo 'readFalse';
}


?>


